<?php
	class xl_thongtin extends database
	{
		function LoadAll()
		{
			$sql = "Select * from thongtin";
			$this->setQuery($sql);
			$arr = $this->loadAllRow();
			$this->disconnect(); 
			return $arr;
		}
		
		function LayThongTinTheoMa($maloaitrang)
		{
			$sql = "Select * from thongtin where maloaitrang='".$maloaitrang."'";
			$this->setQuery($sql);
			$arr = $this->loadAllRow();
			$this->disconnect(); 
			return $arr;
		}
		
		function Load_DiaChi()
		{
			$sql = "Select * from thongtin where maloaitrang='8'";
			$this->setQuery($sql);
			$arr = $this->loadAllRow();
			$this->disconnect(); 
			return $arr;
		}
		
		function Load_LienKetWeb()
		{
			$sql = "Select * from thongtin where maloaitrang='9'";
			$this->setQuery($sql);
			$arr = $this->loadAllRow();
			$this->disconnect(); 
			return $arr;
		}
		
		function Load_Banner()
		{
			$sql = "Select * from thongtin where maloaitrang='10'";
			$this->setQuery($sql);
			$arr = $this->loadAllRow();
			$this->disconnect(); 
			return $arr;
		}
		
		//Toan - ADD START - 29/2/2012
		function Load_Banner_Theo_TinhTrang($matinhtrang)
		{
			$sql = "Select * from thongtin where maloaitrang='10' and tinhtrang='".$matinhtrang."'";
			$this->setQuery($sql);
			$arr = $this->loadAllRow();
			$this->disconnect(); 
			return $arr;
		}
		//Toan - ADD END - 29/2/2012
		
		function Load_TuVanOnline()
		{
			$sql = "Select * from thongtin where maloaitrang='12'";
			$this->setQuery($sql);
			$arr = $this->loadAllRow();
			$this->disconnect(); 
			return $arr;
		}
		//Toan - MOD START - 3/3/2012
		function Load_Background()
		{
			$sql = "Select * from thongtin where maloaitrang='14'";
			$this->setQuery($sql);
			$arr = $this->loadOneRow();
			$this->disconnect(); 
			return $arr;
		}
		//Toan - MOD START - 3/3/2012
		
		
		//Toan - ADD START - 2/3/2012
		function Load_Banner_Theo_ID($ID)
		{
			$sql = "Select * from thongtin where maloaitrang='10' and mathongtin='".$ID."'";
			$this->setQuery($sql);
			$arr = $this->loadAllRow();
			$this->disconnect(); 
			return $arr;
		}
		function XoaBanner($mathongtin)
		{			
			$sql ="delete from thongtin where maloaitrang='10' and mathongtin = '".$mathongtin."'";
			$this->setQuery($sql);
			return $this->query();	
		}
		
		function ThemBanner($tenthongtin, $noidung, $link, $hinhanh)
		{			
			$sql = "INSERT INTO thongtin(maloaitrang, tenthongtin, noidung, link, hinhanh) VALUES (10, '".$tenthongtin."','".$noidung."','".$link."','".$hinhanh."')";			
			$this->setQuery($sql);
			return $this->query();
			//return $sql;
		}
		
		function CapNhatBanner($mathongtin, $tenthongtin, $noidung, $link)
		{	
			$sql = "UPDATE thongtin SET tenthongtin = '".$tenthongtin."', noidung = '".$noidung."', link = '".$link."' WHERE maloaitrang = '10' AND mathongtin = '".$mathongtin."'";
			$this->setQuery($sql);
			return $this->query();
			//return $sql;
		}
		
		function Load_LienKetWeb_Theo_ID($ID)
		{
			
			$sql = "Select * from thongtin where maloaitrang='9' and mathongtin='".$ID."'";
			$this->setQuery($sql);
			$arr = $this->loadAllRow();
			$this->disconnect(); 
			return $arr;
		}
		
		function XoaLienKetWeb($mathongtin)
		{			
			$sql ="delete from thongtin where maloaitrang='9' and mathongtin = '".$mathongtin."'";
			$this->setQuery($sql);
			return $this->query();	
		}
		
		function ThemLienKetWeb($tenthongtin, $link, $hinhanh)
		{			
			$sql = "INSERT INTO thongtin(maloaitrang, tenthongtin, link, hinhanh) VALUES ('9', '".$tenthongtin."','".$link."','".$hinhanh."')";			
			$this->setQuery($sql);
			return $this->query();
			//return $sql;
		}
		
		function CapNhatLienKetWeb($mathongtin, $tenthongtin, $link)
		{	
			$sql = "UPDATE thongtin SET tenthongtin = '".$tenthongtin."', link = '".$link."' WHERE maloaitrang = '9' AND mathongtin = '".$mathongtin."'";
			$this->setQuery($sql);
			return $this->query();
			//return $sql;
		}
		
		function Load_Thong_Tin_Theo_Loai_Trang_va_ID($maloaitrang, $ID)
		{
			$sql = "Select * from thongtin where maloaitrang='".$maloaitrang."' and mathongtin='".$ID."'";
			$this->setQuery($sql);
			$arr = $this->loadAllRow();
			$this->disconnect(); 
			return $arr;
		}
		
		function Xoa_Thong_Tin_Theo_Loai_Trang_va_ID($maloaitrang, $ID)
		{			
			$sql ="delete from thongtin where maloaitrang='".$maloaitrang."' and mathongtin = '".$ID."'";
			$this->setQuery($sql);
			return $this->query();	
		}
		
		function ThemDiaChi($tenthongtin, $noidung)
		{			
			$sql = "INSERT INTO thongtin(maloaitrang, tenthongtin, noidung) VALUES ('8', '".$tenthongtin."','".$noidung."')";			
			$this->setQuery($sql);
			return $this->query();
			//return $sql;
		}
		
		function CapNhatDiaChi($mathongtin, $tenthongtin, $noidung)
		{	
			$sql = "UPDATE thongtin SET tenthongtin = '".$tenthongtin."', noidung = '".$noidung."' WHERE maloaitrang = '8' AND mathongtin = '".$mathongtin."'";
			$this->setQuery($sql);
			return $this->query();
			//return $sql;
		}
		
		function ThemNickYahoo($tenthongtin, $noidung)
		{			
			$sql = "INSERT INTO thongtin(maloaitrang, tenthongtin, noidung) VALUES ('12', '".$tenthongtin."','".$noidung."')";			
			$this->setQuery($sql);
			return $this->query();
			//return $sql;
		}
		//Toan - ADD END - 2/3/2012
	}
?>